import {defineStore} from 'pinia'
import {ref, computed, reactive} from "vue";


export const useContentMenuStore = defineStore('contentMenuStore', () => {

    // 是否打开自定义菜单
    let isOpen = ref(false)

    let isShow = computed(()=>{
        return isOpen
    })
    // 鼠标点击的位置
    let position = reactive({
        height: 0,
        width: 0
    })
    // 菜单数据
    let menuDate = reactive([{name: '刷新', action: 'flash',}])

    const openContextmenu = (e) => {
        e.preventDefault();
        isOpen.value = true
        console.log(isOpen.value)
        position.width = e.clientX;
        position.height = e.clientY;

    }

    const setOpenFalse = (e)=>{
        isOpen.value=false
        console.log(isOpen.value)
    }




    return {
        isOpen, isShow, position, menuDate, openContextmenu,setOpenFalse
    }
})
